package com.quzhi.sys.controller.orderController;

import com.quzhi.common.Result;
import com.quzhi.sys.entity.OrderRemark;
import com.quzhi.sys.service.impl.OrderRemarkServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Xibing
 * @since 2024-07-03
 */
@RestController
@RequestMapping("/sys/orderRemark")
public class OrderRemarkController {

    @Autowired
    private OrderRemarkServiceImpl orderRemarkService;


    @GetMapping("/list")
    public Result<?> getRemarks(){
        List<OrderRemark> list = orderRemarkService.list();

        return Result.success(list);
    }


    @GetMapping("/{id}")
    public Result<?> getRemarkById(@PathVariable("id") String id){
        OrderRemark byId = orderRemarkService.getById(id);

        return Result.success(byId);
    }


    // 添加备注
    @PostMapping
    public Result<?> addRemark(@RequestBody OrderRemark orderRemark){

        return orderRemarkService.addOrderRemark(orderRemark);

    }

    // 更新备注
    @PutMapping
    public Result<?> updateRemark(@RequestBody OrderRemark orderRemark){

        return orderRemarkService.updateOrderRemark(orderRemark);
    }

    // 删除备注
    @DeleteMapping("/{id}")
    public Result<?> deleteById(@PathVariable("id") String id){
        orderRemarkService.removeById(id);
        return Result.success("删除成功");
    }

}
